package com.ruoyi.deeplearn.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.deeplearn.domain.DeepModelSampleTask;
import com.ruoyi.deeplearn.service.IDeepModelSampleTaskService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模型样本Controller
 * 
 * @author rww
 * @date 2024-09-07
 */
@RestController
@RequestMapping("/deeplearn/datesetSampleTask")
public class DeepModelSampleTaskController extends BaseController
{
    @Autowired
    private IDeepModelSampleTaskService deepModelSampleTaskService;

    /**
     * 查询模型样本列表
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datesetSampleTask:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepModelSampleTask deepModelSampleTask)
    {
        startPage();
        List<DeepModelSampleTask> list = deepModelSampleTaskService.selectDeepModelSampleTaskList(deepModelSampleTask);
        return getDataTable(list);
    }

    /**
     * 导出模型样本列表
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datesetSampleTask:export')")
    @Log(title = "模型样本", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepModelSampleTask deepModelSampleTask)
    {
        List<DeepModelSampleTask> list = deepModelSampleTaskService.selectDeepModelSampleTaskList(deepModelSampleTask);
        ExcelUtil<DeepModelSampleTask> util = new ExcelUtil<DeepModelSampleTask>(DeepModelSampleTask.class);
        util.exportExcel(response, list, "模型样本数据");
    }

    /**
     * 获取模型样本详细信息
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datesetSampleTask:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(deepModelSampleTaskService.selectDeepModelSampleTaskById(id));
    }

    /**
     * 新增模型样本
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datesetSampleTask:add')")
    @Log(title = "模型样本", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepModelSampleTask deepModelSampleTask)
    {
        return toAjax(deepModelSampleTaskService.insertDeepModelSampleTask(deepModelSampleTask));
    }

    /**
     * 修改模型样本
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datesetSampleTask:edit')")
    @Log(title = "模型样本", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepModelSampleTask deepModelSampleTask)
    {
        return toAjax(deepModelSampleTaskService.updateDeepModelSampleTask(deepModelSampleTask));
    }

    /**
     * 删除模型样本
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datesetSampleTask:remove')")
    @Log(title = "模型样本", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deepModelSampleTaskService.deleteDeepModelSampleTaskByIds(ids));
    }
}
